// 搜索功能
document.querySelector('.search-input').addEventListener('input', function(e) {
	const searchText = e.target.value.toLowerCase();
	const rows = document.querySelectorAll('tbody tr');

	rows.forEach(row => {
		const className = row.children[0].textContent.toLowerCase();
		row.style.display = className.includes(searchText) ? '' : 'none';
	});
});

// 年级筛选
document.querySelector('.grade-select').addEventListener('change', function(e) {
	const grade = e.target.value;
	const rows = document.querySelectorAll('tbody tr');

	rows.forEach(row => {
		const rowGrade = row.children[1].textContent;
		if (!grade || rowGrade === grade) {
			row.style.display = '';
		} else {
			row.style.display = 'none';
		}
	});
});

// 编辑和删除按钮
document.querySelectorAll('.action-btn').forEach(btn => {
	btn.addEventListener('click', function() {
		const action = this.textContent;
		const row = this.closest('tr');
		const className = row.children[0].textContent;

		if (action === '编辑') {
			alert(`编辑班级: ${className}`);
		} else if (action === '删除') {
			if (confirm(`确定要删除班级 ${className} 吗？`)) {
				row.remove();
			}
		}
	});
});
// 分页按钮
document.querySelectorAll('.page-btn').forEach(btn => {
	btn.addEventListener('click', function() {
		if (this.textContent === '上一页' || this.textContent === '下一页') {
			return;
		}
		document.querySelectorAll('.page-btn').forEach(b => b.classList.remove('active'));
		this.classList.add('active');
	});
});